extends layout

block content
  include includes/navbar.pug
  h1 图片分享
  .row
    .col-12.col-md-8
      if user
        .card.m-1
          h3.card-title 图片上传
          .card-body
            form(action="/images/", method="post", enctype="multipart/form-data")
              .form-group.row
                label.col-sm-2 浏览
                input.col-sm-10.form-control-file(type='file',name='imgfile')
              .form-group.row
                label.col-sm-2 标题
                input.col-sm-8.form-control(type='text', name='title')
              .form-group.row
                label.col-sm-2 描述
                input.col-sm-8.form-control(type='text', name='description')
              .form-group.row
                .offset-md-8.col-sm-2
                  button.btn.btn-primary.btn-block(type='submit') 提交
      else
        .card.m-1
          h3.card-title 未登录，请登陆后可上传图片
    .col-12.col-md-4
      include includes/stats.pug
  .row
    .col-12.col-md-8
      .row
        each image in images
          a.col-6.col-md-4(href=`/images/show/${image._id}`)
            .card
              img.card-img-top(src=`/uploads/${image.diskfilename}`, alt=image.description)
              .card-body
                p.card-text= image.title
    .col-12.col-md-4
      .card.mt-1
          h2.card-title 最近评论
          .card-body  
          
            each val in [0, 1,2 ]
              .card-body 
                a(href=`/images/show/${nearimage[0]._id}`)
                  p.alert.alert-primary= `昵称：${comments[val].nickname} 对图片标题为 ${nearimage[0].title} 的图片评价:`
                p.alert.alert-success.text-left= `评论内容：${comments[val].comment}`
                p.alert.alert-dark= comments[val].createdAt
  block footer
    .mx-auto(style='width:200px') powerd  by 软件163戴辰飞  
